
<html >
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="author" content="diepbap" />

	<title>Login</title>
   
    <link href="admin/css/login.css" rel="stylesheet" type="text/css" />
    
</head>

<body >
<?php
    include ("lib_db.php");
	if(!isset($_SESSION)){ session_start();}
	$ten='';
	if(isset($_POST['login']))
{
	if(isset($_REQUEST['username'])){$username=$_REQUEST['username'];}
	if(isset($_REQUEST['password'])){$pass=$_REQUEST['password'];}
	$sql="select * from user where user='$username'";
	//echo $sql;exit();
	$user=select_one($sql);
	if(!$user)
	{
		echo "<script>alert('Không tồn tại username ');window.location='login.php';</script>";exit();
	}
	else
	{
		$_SESSION['ten']=$user['user'];
			if(md5($pass)!=$user['pass'])
			{
				echo "<script>alert('Password không đúng'); window.location='login.php';</script>";exit();
			}
			
		
			header("Location:index.php");
			exit();
			
	}
}
?>

<div class="wrapper">
	<div class="header">
		
	</div>
	<div class="clear"></div>
	
		<div class="content" style="float:left;">
			<div class="formlogin">
				<div class="title"><h3>ĐIỆP BẮP 1992</h3></div>
				
				<?php
					$u = isset($_COOKIE['us']) ? $_COOKIE['us'] : null;
					$p = isset($_COOKIE['ps']) ? $_COOKIE['ps'] : null;
				?>
				<div class="formcontent">
						<form action="process.php" method="post">
						<fieldset>
								<dl>
									<dt><label>Username:</label></dt>
									<dd><input type="text" id="username" value="<?php echo $u?>" name="txtUser" size="54"/></dd>
								</dl>
								<dl>
									<dt><label>Password:</label></dt>
									<dd><input type="password" id="password" name="txtPass" value="<?php echo $p;?>" size="54"/></dd>
								</dl>
								<dl>
									<dt></dt>
									<dd>
										<input type="checkbox" name="remember" value=""/>
										<label>Remember me</label>
									</dd>
								</dl>
								<dl>
								<dt></dt>
								<dd><input class="enter" name="btnLogin" type="submit" value="Enter"/></dd>
								</dl>	
						 </fieldset>
						</form>	
				</div>
		
				
			</div>
		</div>
	<div class="clear"></div>
	<div class="footer"></div>
</div>
</body>
</html>